<template>
	<view class="content">
		<view class="logisticsCode">
			<text class="status">{{msgDict.delivery}}:{{deliveryCode}}</text>
			<text class="code">{{showType}}</text>
		</view>
		<view class="item" v-for="(item,index2) in list" :key="index2">
			<view class="title">{{msgDict.goodsCode}}：{{item.goodsCode}}</view>
			<view class="centerView">
				<view class="goodsName">
					{{item.goodsName}}
				</view>
				<view class="orderNum">
					x{{item.goodsNum}}
				</view>
			</view>
			<view class="goodsSize">
				{{msgDict.size}}:{{item.size}}
			</view>
			
		</view>
		<view class="btnPopSizeGroup" v-if="showType == '待收货'">
			<view class="btnPopSize showBtnBackColor" @click="btnSizeConfirmSex">
				{{msgDict.confirmReceipt}}
			</view>
		</view>
	</view>
</template>

<script>
	import {deliveryBatchInfos,ensureOrder} from '../../api/index.js'
	export default {
		data() {
			return {
				list:[],
				userId:undefined,
				deliveryCode:'',
				orderCode:'',
				showType:'已收货',
				msgDict:{}
			}
		},
		onLoad(options) {
			
		   this.msgDict = getApp().globalData.$t('logisticsGoods');
		   this.userId = getApp().globalData.userId;
			if (options.orderCode) {
			    this.showType = options.izFinished
				this.deliveryCode = options.deliveryCode
				this.orderCode = options.orderCode
				this.requstOrderInfo({deliveryCode:options.deliveryCode,type:'1'});
			
			}
			
		},
		methods: {
			async requstOrderInfo(dict){
				
				let {result} = await deliveryBatchInfos(dict);
			    this.list = result;           
			
			},
			async requstEnsureOrder(dict){
				
				
				let res = await ensureOrder(dict);
			     
				 uni.showToast({
				 	title:'收货成功',
				 	icon:'none'
				 })
				 let pages = getCurrentPages();
				 let page = pages[pages.length - 2];
				 page.$vm.isRefresh = true;
				setTimeout(()=>{
					
					uni.navigateBack({
						delta:1
					})

				},1200)
				 
				   
			
			},
			btnSizeConfirmSex(){
				uni.showModal({
					title:'注意',
					content:'是否确认收货',
					success:(res)=> {
						if (res.confirm) {
						 this.requstEnsureOrder({userId:this.userId,orderCode:this.orderCode,deliveryCode:this.deliveryCode})
						}
					}
				})
			}
		}
	}
</script>

<style>
	page{
		height: 100%;
		background-color: #f2f2f2;
	}
	.content{
		/* padding: 0rpx 20rpx; */
	}
	.logisticsCode{
		 background-color: #fff;
		 margin-bottom: 20rpx;
		 /* border-bottom-left-radius: 20rpx;
		 border-bottom-right-radius: 20rpx; */
		 padding: 30rpx;
		 display: flex;
		 justify-content: space-between;
		 
	}
	.status{
		 font-size: 36rpx;
		 color: #333;
		 font-weight: 500;
	}
	.code{
		 color: #ccc;
		 font-size: 30rpx;
	}
	.item{
		background-color: #fff;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
	}
	.title{
		padding:30rpx 20rpx;
		border-bottom: thin solid #F2F2F2;
		height: 40rpx;
		font-size: 34rpx;
	}
	.centerView{
		display: flex;
		justify-content: space-between;
		margin-top: 20rpx;
		padding-right: 60rpx;
	}
	
	.goodsName{
		flex: 2;
		font-size: 30rpx;
		color: #333;
		font-weight: 400;

		margin-left: 40rpx;
	}
	.orderNum{
		flex: 1;
		color: #333;
		font-size: 32rpx;
		
	}
	.goodsSize{
		margin-top: 20rpx;
		padding-bottom: 20rpx;
		/* text-align: right; */
		width: 220rpx;
		font-size: 24rpx;
		color: #999;
		margin-left: 40rpx;
	}
	.btnPopSizeGroup{
	  margin-top: 190rpx;	  
	  /* bottom: 20rpx;
	  bottom: calc(20rpx + constant(safe-area-inset-bottom));  
	  bottom: calc(20rpx + env(safe-area-inset-bottom));  */
	}
	.btnPopSize{
					  
	  color: #fff;
	  /* background-color: #FF1493; */
	  height: 84rpx;
	  width: 678rpx;
	  margin: 0 auto;
	  line-height:84rpx;
	  border-radius: 41rpx;
	  font-size: 32rpx;
	  text-align: center;
					  
	}
</style>
